﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ProductManager
{
    public partial class ProviderProduct : Form
    {
        private string _providerID = "";
        public string ProviderID
        {
            get { return _providerID; }
            set { _providerID = value; }
        }

        public ProviderProduct()
        {
            InitializeComponent();
        }

        public void RefreshProduct()
        {
            DataTable products = DBAccess.GetProviderProduct(_providerID);
            if (products != null)
            {
                lvProduct.Items.Clear();
                foreach (DataRow row in products.Rows)
                {
                    lvProduct.Items.Add(new ListViewItem(new string[] {
                        row["Name"].ToString(), row["Price"].ToString() }));
                }
            }
        }

        private void ProviderProduct_Load(object sender, EventArgs e)
        {
            RefreshProduct();
        }
    }
}
